package com.example.administrator.zdtumblr_android_new;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.vov.vitamio.LibsChecker;
import io.vov.vitamio.MediaPlayer;
import io.vov.vitamio.widget.MediaController;
import io.vov.vitamio.widget.VideoView;

public class PlayActivity extends Activity {


    @Bind(R.id.surface_view_new)
    VideoView surfaceViewNew;
    @Bind(R.id.btn_back)
    Button btnBack;
    private MediaController mMediaController;

    private int index;

    private String urls[] = new String[]{
            "http://git.oschina.net/xiaweifeng/xiaweifeng/raw/master/cloudFiles/video/love_story720p.mkv",
            "http://git.oschina.net/xiaweifeng/xiaweifeng/raw/master/cloudFiles/video/诛仙青云志1_1080.mp4",
            "http://git.oschina.net/xiaweifeng/xiaweifeng/raw/master/cloudFiles/video/诛仙青云志2_1080.mp4"
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (!LibsChecker.checkVitamioLibs(this))
            return;
        setContentView(R.layout.activity_play);
        ButterKnife.bind(this);

        if (getIntent() != null) {
            index = getIntent().getIntExtra("index", -1);
        }

        surfaceViewNew.setVideoPath(urls[index]);//设置播放地址
        mMediaController = new MediaController(this);//实例化控制器
        mMediaController.show(2000);//控制器显示5s后自动隐藏
        surfaceViewNew.setMediaController(mMediaController);//绑定控制器
        surfaceViewNew.setVideoQuality(MediaPlayer.VIDEOQUALITY_HIGH);//设置播放画质 高画质
        surfaceViewNew.requestFocus();//取得焦点
    }

    @OnClick(R.id.btn_back)
    public void onClick() {
        finish();
    }
}
